//
//  TSHotAreaViewCell.m
//  TaShuo
//
//  Created by N-X on 2018/1/17.
//  Copyright © 2018年 MRNAN. All rights reserved.
//  热门商圈cell

#import "TSHotAreaViewCell.h"
#import "TSHotAreaItemCell.h"

NSString * const kHotAreaCellID = @"kHotAreaCellID";

@interface TSHotAreaViewCell()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (weak, nonatomic) IBOutlet UIImageView *headerImage;
@property (weak, nonatomic) IBOutlet UILabel *englishNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UICollectionViewFlowLayout *layout;

@end

@implementation TSHotAreaViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.collectionView registerNib:[UINib nibWithNibName:@"TSHotAreaItemCell" bundle:nil] forCellWithReuseIdentifier:kTSHotAreaItemCell];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat itemW = (self.collectionView.nx_width - 6 * 4 ) / 3;
    CGFloat itemH = (self.collectionView.nx_height - 6 * 3) / 2;
    self.layout.itemSize = CGSizeMake(itemW, itemH);
}

#pragma mark - UICollectionViewDelegate && UICollectionViewDataSource

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 6;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    TSHotAreaItemCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:kTSHotAreaItemCell forIndexPath:indexPath];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    !_tsHotAreaItemDidClickBlock ? : _tsHotAreaItemDidClickBlock();
}

@end
